{% extends 'base.html' %}
{% load static %}

{% block 'title' %}购物车{% endblock%}
{% block 'header-title' %}购物车{% endblock%}
{% block 'content' %}
<div class="container">
    {% if total %}
    <div>
        <div class="alert alert-success" role="alert">
            购物车总额：${{total}}
        </div>
        
    </div>
    {% endif %}
    
    <form method="get" class="form-inline float-right my-2">
        <input class="form-control mr-sm-2" type="search" name="name" placeholder="搜索名称" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">搜索</button>
    </form>
    <div class="table-responsive">
        <table class="table  table-hover">
            <thead>
                <tr>
                    <th>#</th>
                    <th>名称</th>
                    <th>价格</th>
                    <th>数量</th>
                    <th>总价</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for item in paginator %}
                <tr>
                    <td>{{forloop.counter0|add:paginator.start_index}}</td>
                    <td><a href="{% url 'show' item.product.pk %}">{{item.title}}</a></td>
                    <td>${{item.price}}</td>
                    <td>{{item.counts}}</td>
                    <td>${{item.total}}</td>
                    <td><a href="{% url 'del' item.product.pk%}">移除</a></td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% include 'message.html' %}
        <p class="btn-toolbar float-right">
            <a class="btn btn-outline-success mr-3" href="{% url 'payit' %}">下一步</a>
            <a class="btn btn-outline-danger" href="{% url 'clear' %}">清空</a>
        </p>
        {% include 'widget-paginator.html' %}
    </div>
</div>
{% endblock %}